package com.akuhome.resource.aspect;

import com.akuhome.resource.util.ResultUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executor;

@Aspect
@Component
public class ResultAspect {

    private Logger logger = LoggerFactory.getLogger(ResultAspect.class);

    @Pointcut("execution(* com.akuhome.resource.controller.*Controller.*(..))")
    public void ResultPointCut(){

    }

    @Around("ResultPointCut()")
    public Object packaging(ProceedingJoinPoint pjp) throws Exception {
        Object ret;
        try{
            ret = pjp.proceed();
        }catch (Throwable e){
            throw (Exception)e;
        }
        return ResultUtil.success(ret);
    }
}
